﻿using System;
using System.ComponentModel;
using System.Web.Mvc;
using ShopB2C.Entity;
using ShopB2C.Enums;
using ShopB2C.Helper;
using ShopB2C.ViewModels;

namespace ShopB2C.Controllers.Brower
{
    public partial class CustomerController
    {
        /// <summary>
        /// 增加到订单
        /// </summary>
        public ActionResult AddToOrder(
             [DefaultValue(0)]int addressId)
        {
            string orderId = string.Format(_orderNo , DateTime.Now.ToString("yyyyMMddHHssmmfff"));
            int result = _orderAccess.AddToOrder(orderId , addressId , _user.Uid,(int)ShopCarType.ShopCar);
            return RedirectToAction("OrderList");
        }
        /// <summary>
        /// 订单列表
        /// </summary>
        public ActionResult OrderList([DefaultValue(0)]int pageIndex)
        {
            this.SiteMapPathAdd("历史订单列表");
            int pageCount = 0;
            OrderViewModel _viewModel = new OrderViewModel();
            _viewModel.OrderList = _orderAccess.SaleList(_user.Uid , pageIndex , ref pageCount);
            return View(_viewModel);
        }
        /// <summary>
        /// 订单预览
        /// </summary>
        public ActionResult OrderView([DefaultValue("")]string orderId , [DefaultValue(0)]int pageIndex)
        {
            this.SiteMapPathAdd("历史订单列表" , Url.Action("OrderList" , new { pageIndex = pageIndex }));
            this.SiteMapPathAdd("订单查看");
            OrderViewModel orderView = _orderAccess.SaleOrderView(_user.Uid , orderId);
            if (orderView == null)
                return Content("订单没有找到!!");
            return View(orderView);
        }
        /// <summary>
        /// 财务记录列表
        /// </summary>
        public ActionResult Bill()
        {
            return View();
        }
    }
}
